package com.example.myfirstapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebViewClient
import com.example.myfirstapplication.utils.BaseActivity
import kotlinx.android.synthetic.main.activity_web_view.*

class WebViewActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_web_view)

        val actionBar=supportActionBar
        actionBar?.hide()
        webView.settings.javaScriptEnabled = true
        webView.canZoomIn()
        webView.canZoomOut()
        //设置自适应屏幕，两者合用
        webView.settings.useWideViewPort = true; //将图片调整到适合webview的大小
        webView.settings.loadWithOverviewMode = true; // 缩放至屏幕的大小
        btnEnter.setOnClickListener {
            val url = address.text.toString()
            webView.webViewClient = WebViewClient()
            webView.loadUrl(url)
        }
        btnForward_web.setOnClickListener {
            webView.goForward()
        }
        btnBack_web.setOnClickListener {
            webView.goBack()
        }
        btnRefresh_web.setOnClickListener {
            webView.reload()
        }
    }

}